// 创建全局的vuex
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const module = {
  state:{
    arr:[],
    bold:false,
    nichen:'夏至未至',
    pone:'15012340809',
    shen:100
  },
  //mutations存放修改state中值的事件
  mutations:{
    tianjia(state,obj){
      if (obj.bols) {
        state.arr.push(obj)
      }
      this.state.bold = true;
    },
    dels(state,i){
      state.arr.splice(i,1);
    },
    alldel(state){
      state.arr.splice(0,state.arr.length);
    },
    xiugai(state,val){
      state.nichen = val;
      alert('修改成功');
    },
    bdpon(state,val){
      state.pone = val;
      alert('绑定成功');
    }
  }
};

const store = new Vuex.Store(module);

export default store;
